package com.wxl.common.base

import android.annotation.SuppressLint
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import androidx.viewpager.widget.PagerAdapter

/**
 * create file time : 2021/3/11
 * create user : wxl
 * subscribe :
 */
class TabLayoutPageFragmentAdapter : FragmentPagerAdapter {

    var data: ArrayList<AbsFragment>

    @SuppressLint("WrongConstant")
    constructor(data: ArrayList<AbsFragment>, fm: FragmentManager) : super(
        fm,
        BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
    ) {
        this.data = data
    }


    override fun getItem(position: Int): Fragment {
        return data[position]
    }


    override fun getCount(): Int {
        return data.size
    }

    override fun getItemPosition(`object`: Any): Int {
        return PagerAdapter.POSITION_NONE
    }

    override fun getPageTitle(position: Int): CharSequence? {
        return data[position].getTitle()
    }
}